﻿<%@ Page Title="<%$Resources:PageTitle %>" Language="C#" MasterPageFile="~/MasterPages/Core.Master" AutoEventWireup="true"
    CodeBehind="UserDetails.aspx.cs" Inherits="Pap.Web.Modules.Membership.Views.UserDetails" %>

<asp:Content ContentPlaceHolderID="ContentPlaceHolder1" runat="server">

    <script type="text/javascript">
        Ext.apply(Ext.form.VTypes,
        {
            'password': function(val, field) {
                var pass = Ext.getCmp('txtPass');
                var confirm = field;
                return (val == pass.getValue());
            }
        });

        function CheckUserNameExist(v, e) {
            Pap.ValidateName();
        }

        function CheckEmailExist(v, e) {
            Pap.ValidateEmail();
        }
    </script>

    <ext:Store runat="server" ID="storeProject">
        <Reader>
            <ext:JsonReader ReaderID="ProjectID">
                <Fields>
                    <ext:RecordField Name="ProjectName">
                    </ext:RecordField>
                    <ext:RecordField Name="ProjectID">
                    </ext:RecordField>
                </Fields>
            </ext:JsonReader>
        </Reader>
    </ext:Store>

    <ext:FitLayout runat="server">
        <ext:FormPanel ID="MainForm" runat="server" IDMode="Static" Frame="true" AutoScroll="true"
            Border="true" BodyStyle="padding:10px 10px 0;" meta:resourcekey="MainFormResource1">
            <Defaults>
                <ext:Parameter Name="Anchor" Value="95%" />
                <ext:Parameter Name="SelectOnFocus" Value="true" Mode="Raw" />
            </Defaults>
            <Body>
                <ext:FormLayout runat="server">
                    <ext:Anchor Horizontal="70%">
                        <ext:TextField ID="txtUserName" runat="server" meta:resourcekey="txtUserNameResource1"
                            MaxLength="50" AllowBlank="false">
                        </ext:TextField>
                    </ext:Anchor>
                    <ext:Anchor Horizontal="70%">
                        <ext:TextField ID="txtPass" runat="server" InputType="Password" meta:resourcekey="txtPassResource1"
                            Text="" MaxLength="50" AllowBlank="false" />
                    </ext:Anchor>
                    <ext:Anchor Horizontal="70%">
                        <ext:TextField ID="txtConfirmPassword" runat="server" InputType="Password" Vtype="password"
                            VtypeText="<%$ Resources:PasswordConfirmationError %>" meta:resourcekey="txtConfirmPasswordResource1"
                            MaxLength="50" AllowBlank="false" />
                    </ext:Anchor>
                    <ext:Anchor Horizontal="70%">
                        <ext:TextField ID="txtDisplayName" runat="server" meta:resourcekey="txtDisplayNameResource1"
                            MaxLength="50" AllowBlank="false" />
                    </ext:Anchor>
                    <ext:Anchor Horizontal="70%">
                        <ext:DateField ID="dtpBirthDate" runat="server" AllowBlank="false" NoteAlign="Down"
                            meta:resourcekey="dtpBirthDateResource1" Format="dd-MM-yyyy" />
                    </ext:Anchor>
                    <ext:Anchor Horizontal="70%">
                        <ext:TextField ID="txtJobTitle" runat="server" meta:resourcekey="txtJobTitleResource1"
                            MaxLength="50" />
                    </ext:Anchor>
                    <ext:Anchor Horizontal="70%">
                        <ext:TextField ID="txtEmail" runat="server" Vtype="email" meta:resourcekey="txtEmailResource1"
                            MaxLength="50">
                        </ext:TextField>
                    </ext:Anchor>
                    <ext:Anchor Horizontal="70%">
                        <ext:Panel ID="panelCommittees" runat="server" Frame="true" Title="<%$Resources:panelCommitteesTitle %>"
                            AutoScroll="true">
                            <Body>
                                <asp:DataList runat="server" ID="lstcommittees" RepeatColumns="3" Width="100%" Height="100%"
                                    RepeatDirection="Horizontal" meta:resourcekey="llstcommitteeResource1">
                                    <ItemTemplate>
                                        <asp:HiddenField ID="txtID" runat="server" Value='<%# Eval("CommitteeID") %>' />
                                        <ext:Checkbox ID="chkSelect" runat="server" IDMode="Legacy" BoxLabel='<%# Eval("CommitteeName") %>' />
                                    </ItemTemplate>
                                </asp:DataList>
                            </Body>
                        </ext:Panel>
                    </ext:Anchor>
                    <ext:Anchor Horizontal="70%" Vertical="100%">
                        <ext:Panel ID="pnlRoles" Frame="True" Title="Roles" runat="server" AutoScroll="True"
                            AutoHeight="True" meta:resourcekey="pnlRolesResource1" IDMode="Static">
                            <Body>
                                <asp:DataList runat="server" ID="lstRole" RepeatColumns="3" Width="100%" Height="100%"
                                    RepeatDirection="Horizontal" meta:resourcekey="lstRoleResource1">
                                    <ItemTemplate>
                                        <asp:HiddenField ID="txtID" runat="server" Value='<%# Eval("RoleID") %>' />
                                        <ext:Checkbox ID="chkSelect" runat="server" IDMode="Legacy" BoxLabel='<%# Eval("RoleName") %>' />
                                    </ItemTemplate>
                                </asp:DataList>
                            </Body>
                        </ext:Panel>
                    </ext:Anchor>
                    <ext:Anchor Horizontal="70%">
                        <ext:Panel ID="panelProjects" runat="server" Frame="true" Title="<%$Resources:panelProjectsTitle %>"
                            AutoScroll="true">
                            <Body>
                                <asp:DataList runat="server" ID="lstProjects" RepeatColumns="3" Width="100%" Height="100%"
                                    RepeatDirection="Horizontal" meta:resourcekey="llstProjectResource1">
                                    <ItemTemplate>
                                        <asp:HiddenField ID="txtID" runat="server" Value='<%# Eval("ProjectID") %>' />
                                        <ext:Checkbox ID="chkSelect" runat="server" IDMode="Legacy" BoxLabel='<%# Eval("ProjectName") %>' />
                                    </ItemTemplate>
                                </asp:DataList>
                            </Body>
                        </ext:Panel>
                    </ext:Anchor>
                </ext:FormLayout>
                
                <asp:CustomValidator runat="server" ControlToValidate="txtUserName" OnServerValidate="txtUserName_Validate"
                    ClientValidationFunction="CheckUserNameExist" />
                <asp:CustomValidator runat="server" ControlToValidate="txtEmail" OnServerValidate="txtEmail_Validate"
                    ClientValidationFunction="CheckEmailExist" />
                <asp:CustomValidator runat="server" OnServerValidate="lstRole_Validate" />
                <asp:CustomValidator runat="server" OnServerValidate="lstCommittee_Validate" />
                <asp:CustomValidator runat="server" OnServerValidate="lstProject_Validate" />
            </Body>
            <BottomBar>
                <ext:StatusBar ID="FormStatusBar" runat="server" DefaultText="Ready" meta:resourcekey="FormStatusBarResource1">
                    <Plugins>
                        <ext:ValidationStatus ID="pnlValidation" FormPanelID="MainForm" ValidIcon="Accept"
                            ErrorIcon="Exclamation" meta:resourcekey="pnlValidationResource1" />
                    </Plugins>
                    <Items>
                        <ext:Button ID="btnCancel" Text="Cancel" runat="server" Icon="Cancel" meta:resourcekey="btnCencelResource1">
                            <AjaxEvents>
                                <Click OnEvent="btnCancel_Clicked" />
                            </AjaxEvents>
                        </ext:Button>
                        <quadz:CoolitePermitButton ID="btnSubmit" Text="Submit" runat="server" Icon="Disk"
                            meta:resourcekey="btnSubmitResource1" PermissionName="AddEditUser" HideAsDisabled="true">
                            <AjaxEvents>
                                <Click OnEvent="btnSubmit_Clicked" Before="var valid= #{MainForm}.getForm().isValid(); return valid;" />
                            </AjaxEvents>
                        </quadz:CoolitePermitButton>
                    </Items>
                </ext:StatusBar>
            </BottomBar>
        </ext:FormPanel>
    </ext:FitLayout>
</asp:Content>
